home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 560 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do you clear the keyboard buffer in c?
  5. Date: 6 Jan 1996 21:28:18 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4cnb42$2fn@umbc9.umbc.edu>
  8. References: <4ao8ed$q9h@news.aloha.com> <NEWTNews.819188338.12128.silver@dialup.netvision.net.il> <4cl3v1$4u1@news-e2a.gnn.com>
  9. NNTP-Posting-Host: f-umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. Kevin Kalstein <MrBurns@gnn.com> wrote:
  13. |> hmm, i think you can also do:
  14. |> 
  15. |> fflush(stdin);
  16.  
  17. If you only 'think' and don't actually 'know' then perhaps it is best not
  18. to give possibly incorrect advice which can mess up the original poster
  19. even more. I'm honestly not trying to be a smart***, but this is a FAQ!
  20.  
  21. 12.26:    How can I flush pending input so that a user's typeahead isn't
  22.     read at the next prompt?  Will fflush(stdin) work?
  23.  
  24. A:    fflush() is defined only for output streams.  Since its
  25.     definition of "flush" is to complete the writing of buffered
  26.     characters (not to discard them), discarding unread input would
  27.     not be an analogous meaning for fflush on input streams.
  28.  
  29.     There is no standard way to discard unread characters from a
  30.     stdio input stream, nor would such a way be sufficient unread
  31.     characters can also accumulate in other, OS-level input buffers.
  32.  
  33.     References: ANSI Sec. 4.9.5.2; ISO Sec. 7.9.5.2; H&S Sec. 15.2.
  34. -- 
  35. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  36.  
  37. Jonas J. Schlein  (schlein@gl.umbc.edu)
  38.